const state = {
  customerManageData: [],
  customerManageDataCount: 0
}

const mutations = {
  GET_CUSTOMER_MANAGE_DATA: (state, data) => {
    state.customerManageData = data
  },
  GET_CUSTOMER_MANAGE_DATA_COUNT: (state, data) => {
    state.customerManageDataCount = data
  }
}

const actions = {
  async getCustomerManageData({ commit }, playload) {
    let data = {}
    let newData = []
    if (Object.keys(playload).length > 0) {
      data = playload
    }
    for (let i = 0; i < 6; i++) {
      newData = [...newData, {
        id: i + 1,
        host: 'http://static.baisha.work',
        pnumber: '010',
        name: '李思思',
        tel: '13775237256',
        idcard: '320402199106292929',
        sex: '0',
        ctime: '2019-04-24 14:58:00',
        pcardimg: '',
        ncardimg: '',
        driveimg: ''
      }]
    }
    commit('GET_CUSTOMER_MANAGE_DATA', newData)
    commit('GET_CUSTOMER_MANAGE_DATA_COUNT', newData.length)
    // const resp = await getCustomerTable(data)
    // resp.data.data.rows.map((item) => {
    //   if ((item.state === 3 || item.state === 4 || item.state === 5 || item.state === 6) && item.state0 === 0) {
    //     newData = [...newData, {
    //       id: item.id,
    //       uid: item.uid,
    //       ctime: item.ctime,
    //       uname: item.uname,
    //       tel: item.tel,
    //       coludname: item.coludname,
    //       coludtel: item.coludtel,
    //       mname: item.mname,
    //       pname: item.pname,
    //       puid: item.puid,
    //       appointime: item.appointime,
    //       state: item.state.toString(),
    //       comdate: item.comdate,
    //       tname: item.tname,
    //       gid: item.gid,
    //       gname: item.gname,
    //       orderdate: item.orderdate,
    //       cprice: item.cprice,
    //       commission: item.commission,
    //       state0: item.state0,
    //       ttype: item.ttype ? item.ttype.toString() : '',
    //       remarks: item.remarks,
    //       perrate: item.perrate,
    //       permoney: item.permoney,
    //       budget: item.budget,
    //       difftime: item.difftime,
    //       lostdate: item.lostdate,
    //       sex: item.sex,
    //       age: item.age || item.age === 0 ? item.age.toString() : '',
    //       want: item.want || item.want === 0 ? item.want.toString() : ''
    //     }]
    //   }
    // })
    // commit(ARRIVE_LIST, newData)
    // commit(ARRIVE_DATA_COUNT, resp.data.data.total)
    // if (newData.length < rootState.arrive.arrivePageSize) {
    //   commit(ARRIVE_HISTORY_DATA, newData)
    // } else {
    //   commit(ARRIVE_HISTORY_DATA, newData.slice(0, rootState.arrive.arrivePageSize))
    // }
    // return resp
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
